<?php

class Application_Model_DbTable_Stops extends Zend_Db_Table_Abstract
{

    protected $_name = 'stop';
	
	public function getBusstop($id)
	{
		$id = (int)$id;
		$row = $this->fetchRow('id = '. $id);
			if (!$row) {
				throw new Exception("Could not find row $id");
			}
			return $row->toArray();
	}
	
		public function addBusstop($name, $latitude, $longitude)
		{
			$data = array(
			'name' => $name,
			'latitude' => $latitude,
			'longitude'=> $longitude,
			);
		$this->insert($data);
		}
		
		public function updateBusstop($id, $name, $latitude, $longitude)
		{
			$data = array(
			'name' => $name,
			'latitude' => $latitude,
			'longitude'=>$longitude,
			);
		$this->update($data, 'id = '. (int)$id);
		}
		
		public function deleteBusstop($id)
		{
			$this->delete('id =' . (int)$id);
		}
		
		public function findByBusstopName($busstopname)
		{
			$query = $this->select();
			$query->where('name = ?', $busstopname);
			$result = $this->fetchRow($query);
			return result;
		}


}

